import 'package:freezed_annotation/freezed_annotation.dart';

part 'payments_model.freezed.dart';

part 'payments_model.g.dart';

@freezed
class PaymentsModel with _$PaymentsModel {
  const factory PaymentsModel({
    required SummaryModel summary,
    @Default([]) List<PaymentsGoodsModel> goods,
    @Default([]) List<PaymentsUserAddressesModel> userAddresses,
  }) = _PaymentsModel;

  factory PaymentsModel.fromJson(Map<String, dynamic> json) => _$PaymentsModelFromJson(json);
}

@freezed
class PaymentsGoodsModel with _$PaymentsGoodsModel {
  const factory PaymentsGoodsModel({
    required int count,
    required String attrsText,
    required String id,
    required String name,
    required String payPrice,
    required String picture,
    required String price,
    required String skuId,
    required String totalPayPrice,
    required String totalPrice,
  }) = _PaymentsGoodsModel;

  factory PaymentsGoodsModel.fromJson(Map<String, dynamic> json) => _$PaymentsGoodsModelFromJson(json);
}

@freezed
class SummaryModel with _$SummaryModel {
  const factory SummaryModel({
    required int discountPrice,
    required int goodsCount,
    required int postFee,
    required int totalPayPrice,
    required int totalPrice,
  }) = _SummaryModel;

  factory SummaryModel.fromJson(Map<String, dynamic> json) => _$SummaryModelFromJson(json);
}

@freezed
class PaymentsUserAddressesModel with _$PaymentsUserAddressesModel {
  const factory PaymentsUserAddressesModel({
    required int isDefault,
    required String address,
    required String addressTags,
    required String cityCode,
    required String contact,
    required String id,
    required String countyCode,
    required String fullLocation,
    required String postalCode,
    required String provinceCode,
    required String receiver,
  }) = _PaymentsUserAddressesModel;

  factory PaymentsUserAddressesModel.fromJson(Map<String, dynamic> json) => _$PaymentsUserAddressesModelFromJson(json);
}
